package cn.edu.sdjzu.service.impl;//package cn.edu.sdjzu.xg.bysj.service;


import cn.edu.sdjzu.dao.RoleDao;
import cn.edu.sdjzu.entity.authority.Role;
import cn.edu.sdjzu.factory.DaoFactory;
import cn.edu.sdjzu.service.RoleService;
import cn.edu.sdjzu.util.JdbcHelper;

import java.sql.Connection;
import java.sql.SQLException;

public final class RoleServiceImpl implements RoleService {
    RoleDao roleDao = DaoFactory.getDao(RoleDao.class, "RoleDaoImpl");


//	public Collection<Role> findAll(Pagination pagination, List<Condition> conditionList) throws SQLException {
//		//获取数据库连接
//		Connection connection = JdbcHelper.getConn();
//		Collection<Role> roles = roleDao.findAll(connection, pagination, conditionList);
//		//释放连接
//		JdbcHelper.close(connection);
//		return roles;
//	}

	@Override
	public Role find(Integer id) throws SQLException {
		//获取数据库连接
		Connection connection = JdbcHelper.getConn();
		Role role = roleDao.find(connection, id);
		//释放连接
		JdbcHelper.close(connection);
		return role;
	}

//	public boolean update(Role role) throws SQLException {
//		//获取数据库连接
//		Connection connection = JdbcHelper.getConn();
//		boolean updated = roleDao.update(connection, role);
//		//释放连接
//		JdbcHelper.close(connection);
//		return updated;
//	}

//	public boolean add(Role role) throws SQLException {
//		Connection connection = JdbcHelper.getConn();
//		boolean added = roleDao.add(connection, role);
//		JdbcHelper.close(connection);
//		return added;
//	}

//	public boolean delete(Integer id) throws SQLException, BaseException {
//		//获取数据库连接
//		Connection connection = JdbcHelper.getConn();
//		boolean deleted = false;
//		try {
//			deleted = roleDao.delete(connection, id);
//			return deleted;
//		} catch (SQLIntegrityConstraintViolationException e) {
//			throw new BaseException("某员工或学生正在使用当前角色");
//		} finally {
//			//释放连接
//			JdbcHelper.close(connection);
//		}
//
//	}

}
